package com.baomidou.wechat.mp.apistore.actuator;

import org.apache.commons.lang.StringUtils;

import com.alibaba.fastjson.JSON;
import com.baomidou.wechat.mp.apistore.vo.TuringVo;

/**
 * 图灵机器人 Actuator
 * <p>
 * http://apistore.baidu.com/apiworks/servicedetail/736.html
 * </p>
 */
public class TuringActuator extends ApiStoreActuator<TuringVo> {
	private static String API_IP = "turing/turing/turing?key=879a6cb3afb84dbf4fc84a1df2ab7319&userid=eb2edb736&info=%s";
	private String text;
	
	public static void main(String[] args) {
		ApiStoreActuator<TuringVo> actuator = new TuringActuator("你好呀");
		System.out.println(actuator.execute().toString());
	}
	
	public TuringActuator(String text){
		this.text = text;
	}

	@Override
	public TuringVo execute() {
		String json = executeHttpGet(null, API_IP, getText());
		if (StringUtils.isNotBlank(json)) {
			return JSON.parseObject(json, TuringVo.class);
		}
		return null;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

}
